<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="author" content="Guillaume Laborde - Guillaume Lameyre" />
<link rel="stylesheet" media="screen" type="text/css" title="style" href="css/style.css" />
<title>ContactBook</title>
</head>

<body>

	<c:set var="account" value="${sessionScope.account}" />
	<c:set var="message" value="${requestScope.message}" />
	
	<c:if test="${empty account}">
		<c:redirect url="Index" />
	</c:if>
	
	<div id="mainframe">
		<c:import url="include/privateBanner.html" />
		<h1>Modifer le groupe</h1>
		
		<div id="content">
		
			<c:choose>
				<c:when test="${message == 'GROUP_UPDATED_OK'}">
					<form action="Group" method="POST" class="form">
						<table>
							<tr><td>Le groupe a bien été modifié.</td></tr>
							<tr><td class="button"><input type="image" src="images/back.png" alt="Retour" /></td></tr>
						</table>
					</form>
				</c:when>
				<c:when test="${message == 'GROUP_UPDATED_NAME_FAIL'}">
					<p class="error">Le nom du groupe doit être renseigné.</p>
				</c:when>
				<c:when test="${message == 'GROUP_UPDATED_FAIL'}">
					<p class="error">Le modification du groupe a échouée.</p>
				</c:when>
			</c:choose>
		
			<c:if test="${message != 'GROUP_UPDATED_OK'}">
				<jsp:useBean id="group" class="contactbook.model.Group" scope="request" />
				<form action="UpdateGroup" method="POST" class="form">
					<table>
						<tr>
							<td>Nom du groupe</td>
							<td><input type="text" name="name" id="name" value="<jsp:getProperty name="group" property="name" />" /></td>
						</tr>
						<tr>
							<td>Description</td>
							<td><input type="text" name="description" id="description" value="<jsp:getProperty name="group" property="description" />" /></td>
						</tr>
						<tr>
							<td colspan="2" class="button"><input type="submit" name="submit" value="OK" /> <input type="submit" name="submit" value="Annuler" /></td>
						</tr>
					</table>
					<input type="hidden" name="groupId" value="<jsp:getProperty name="group" property="id" />" />
				</form>
			</c:if>
		</div>
		<c:import url="include/bottom.html" />
	</div>

</body>
</html>